<!--
 * @Author: 137 '1432417996@qq.com'
 * @Date: 2025-04-28 23:33:46
 * @LastEditors: 137 '1432417996@qq.com'
 * @LastEditTime: 2025-05-08 03:27:48
 * @FilePath: \starter-3\pages\callback\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div></div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import { ElLoading } from 'element-plus'
import { useHead } from '#app'

// 添加meta标签防止搜索引擎索引
useHead({
  meta: [
    { name: 'robots', content: 'noindex, nofollow' }
  ]
})

onMounted(() => {
  ElLoading.service();
  postMessageToParent();
})

const postMessageToParent = () => {
  // 从 URL 中获取 code
const urlParams = new URLSearchParams(window.location.search);
console.log('urlParams',urlParams)
const code = urlParams.get('code');
const state = urlParams.get('state');
  if (code) {
    console.log('code是',code)
    // 向父窗口发送消息
    window.parent.postMessage({
      type: 'wechat_login',
      code: code,
      state: state
    }, '*');
    setTimeout(() => {
      ElLoading.service().close();
    }, 1000)
  }
}
</script>
<style scoped>

</style>

